package com.pengweiwei.androidzygote.main.ui;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.core.app.ActivityCompat;

import com.cncn.youmengsharelib.ShareData;
import com.cncn.youmengsharelib.ShareListener;
import com.cncn.youmengsharelib.SharePlatform;
import com.pengweiwei.androidzygote.R;
import com.pengweiwei.androidzygote.functions.qrcode.QrCodeDemoActivity;
import com.pengweiwei.androidzygote.functions.share.SharePlatformsFragment;
import com.putong35.common.baseactfrag.fragment.BaseFragment;
import com.putong35.common.baseactfrag.view.CenterToolbar;
import com.putong35.common.utils.EasyToast;

import butterknife.OnClick;


public class ThirdpartIndexFragment extends BaseFragment implements ActivityCompat.OnRequestPermissionsResultCallback{
    public static final String TAG = ThirdpartIndexFragment.class.getSimpleName();
    @OnClick(R.id.btnQrCode)
    public void onBtnQrCodeClicked() {
        Intent intent = new Intent(getActivity(), QrCodeDemoActivity.class);
        startActivity(intent);
//        AccountManager.getAccount().setPortraitUrl("http://files.jb51.net/file_images/article/201703/201703051355471.png");
//        AccountManager.getAccount().setName("haha");

//        AccountManager.getAccount().setPortraitUrl("http://img01.taopic.com/160203/235110-1602030ZP835.jpg");
//        AccountManager.getAccount().setName("woshi ");

    }



    @OnClick(R.id.btnShare)
    public void onBtnShareClicked() {
        String imgUrl = "http://pic.58pic.com/58pic/15/23/09/74T58PICZjg_1024.jpg"; // should not be null
        String targetUrl = "https://www.baidu.com/"; // should not be null
        ShareData shareData = new ShareData("标题", "内容", imgUrl, targetUrl);
        SharePlatformsFragment sharePlatformsFragment = new SharePlatformsFragment(shareData);
        sharePlatformsFragment.setShareListener(new ShareListener() {
            @Override
            public void onShareSuccess(Activity shareActivity, SharePlatform platform) {
                EasyToast.showToast(getActivity(), "test onShareSuccess");
            }

            @Override
            public void onShareFailed(Activity shareActivity, SharePlatform platform) {
                EasyToast.showToast(getActivity(), "test onShareFailed");
            }

            @Override
            public void onShareCancel(Activity shareActivity, SharePlatform platform) {
                EasyToast.showToast(getActivity(), "test onShareCancel");
            }
        });

        sharePlatformsFragment.show(getFragmentManager());
    }




    public ThirdpartIndexFragment() {
        // Required empty public constructor
    }

    /**
     * Use this factory method to create a new instance of
     * this fragment using the provided parameters.
     *
     * @param param1 Parameter 1.
     * @param param2 Parameter 2.
     * @return A new instance of fragment ThemeAttrFragment.
     */
    public static ThirdpartIndexFragment newInstance(String param1, String param2) {
        ThirdpartIndexFragment fragment = new ThirdpartIndexFragment();
        Bundle args = new Bundle();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments() != null) {
        }

    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view = super.onCreateView(inflater, container, savedInstanceState);
        return view;
    }

    @Override
    public View createDataView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_thirdpart_index  , container, false);
        CenterToolbar toolbar = view.findViewById(R.id.toolbar);
        toolbar.setTitle("第三方组件");
        return view; 
    }

}
